package com.rules.admin.expression;

import com.google.common.base.Joiner;
import com.google.common.collect.Lists;

import java.util.List;

public class Fact implements Expression {
   private String factAlias = "$content";
   private String factObject = "Content";
   private List<BinaryExpression> binaryExpressions = Lists.newArrayList();

   public void setFactAlias(String factAlias) {
      this.factAlias = factAlias;
   }

   public void setFactObject(String factObject) {
      this.factObject = factObject;
   }

   public void accept(ExpressionVisitor visitor) {
      visitor.vistor(this);
   }

   public String toString() {
      StringBuilder builder = new StringBuilder();
      builder.append("\t\t" + this.factAlias + ":" + this.factObject + "(").append(Joiner.on("\n\t\t\t,").join(this.binaryExpressions)).append(")");
      return builder.toString();
   }

   public void addCondition(BinaryExpression binaryExpression) {
      this.binaryExpressions.add(binaryExpression);
   }

   public List<BinaryExpression> getBinaryExpressions() {
      return this.binaryExpressions;
   }

   public void setBinaryExpressions(List<BinaryExpression> binaryExpressions) {
      this.binaryExpressions = binaryExpressions;
   }
}
